<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.global.js"></script>
</head>
<body>
    <div id="app">
        <ul>
            <!-- <li v-for="item in arr">{{item}}</li> -->
            <li v-for="(item,index) in arr">{{index}}:{{item}}</li>
        </ul>
        <hr>

        <h3>遍历对象</h3>
        <ul>
            <!-- <li v-for="val in person">{{val}}</li> -->
            <!-- <li v-for="(value,key) in person">{{key}}:{{value}}</li> -->
            <li v-for="(value,key,index) in person">{{index}}  {{key}}:{{value}}</li>
        </ul>
        <hr>

        <h3>循环嵌套</h3>
        <div v-for="(value,key) in person">

            <!-- 如果不是爱好 拿p显示 -->
            <p v-if="key !== 'hobbies'">{{key}}:{{value}}</p>

            <!-- 否则用ul显示 -->
            <ul v-else>
                <!-- <li v-for="item in value">{{item}}</li> -->
                <li v-for="item of value">{{item}}</li>
            </ul>

        </div>

    </div>

    <script>
        Vue.createApp({
            data(){
                return {
                    arr:["a","b","c"],
                    person:{
                        name:"约汉",
                        age:18,
                        gender:"男",
                        hobbies:[
                            "女","抽烟","喝酒","烫头"
                        ]
                    }
                }
            }
        }).mount("#app")
    </script>
    
</body>
</html>